import {reactive} from "vue"
import {list2String} from "../../../../utils/common";

export const tableItem = reactive({
    select: false,
    index: false,
    tree: true,
    expandAll: true,
    align: 'center',
    column: [
			{
				label: '序号',
				prop: 'orderNum'
			},
        {
            label: '名称',
            prop: 'name'
        },
        {
            label: '类型',
            prop: 'categoryName'
        },
        {
            label: '标签',
            prop: 'tagLabel'
        },
        {
            label: '亮点',
            prop: 'tagHighlightList',
            htmlContent: (row)=>{
                return list2String(row.tagHighlightList)
            }
        },
        {
            label: '有效期',
            prop: 'createTime',
            htmlContent: (row)=>{
                let startTime = row.validStartTime
                let endTime = row.validEndTime

                return startTime + "-" + endTime
            }
        },
        {
            label: '创建时间',
            prop: 'createTime'
        },
        {
            label: '上架状态',
            prop: 'publishedFlag',
            htmlContent: (row)=>{
                return row.publishedFlag == 1? '上架' : '下架'
            }
        },
        {
            label: '操作',
            prop: 'action'
        },
    ],
    pageInfo: {
        request: {
            pageDomain:{}
        },
        pagesClose: false,//是否开启分页
        url: '/admin/goods/paging',//分页路由，不传的话需要传入自定义的分页函数paging 传入时定义的分页函数paging会失效
    },
    // 分页数据 自定义分页函数paging时需要把值赋给tableData
    tableData: {
        total: 10,//分页总计
        // 分页数据
        data: []
    },
    // 操作栏按钮
    btnArray: [
        {
            type: 'primary',//类别 摈弃了text
            code: 'detail',
            label: 'SKU表',
        },
        {
            type: 'primary',//类别 摈弃了text
            label: '修改',
            code: 'edit',
        },
        {
            type: 'primary',//类别 摈弃了text
            label: '上架',
            code: 'published',
            showFunction: (row)=>{
                return row.publishedFlag == 0;
            },
        },
        {
            type: 'danger',//类别 摈弃了text
            label: '下架',
            code: 'unpublished',
            showFunction: (row)=>{
                return row.publishedFlag == 1;
            },
        },
    ],
    // 选择框触发
    selectChange: function (row) {
        console.log(row)
    },
})

// 名称、课程大类、有效期、是否有活动、上架状态

export const operationItem = reactive({
    defaultSearch: true,//默认搜索按钮
    defaultRefresh: true,//默认重置按钮
    customTableHeader: false,//

    // 封面、名称、课程大类、销量、标签、特色（多选）、有效期、上架状态、是否有活动（待定）、创建时间
    SearchItem: [
        {
            code: 'name',
            name: '名称',
            type: 'input',
        },
        {
            code: 'categoryId',
            name: '类型',
            type: 'select',
            label: 'name',
            value: 'id'
        },
        {
            code: 'publishedFlag',
            name: '状态',
            type: 'select',
            placeholder: '请选择状态',
            options: [
                { label: '上架', value: 1 },
                { label: '下架', value: 0 }
            ]
        },
        {
            code: 'examYear',
            name: '年份',
            type: 'input',
        },
    ],
    menuArray: [
        {
            show: true,
            code:'add',
            type: 'primary',
            text: '新增'
        },
    ]
})
